package com.vcredit.creditcat.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.vcredit.creditcat.model.ProductBusinessStatus;
import com.vcredit.creditcat.framework.pagination.Criteria;
import com.vcredit.creditcat.framework.pagination.Page;
import com.vcredit.creditcat.persistence.base.ProductBusinessStatusMapper;

 /*
  * @author liaoshengjun
  * @version 1.0
  * @since 1.0
 */
@Service
public class ProductBusinessStatusService {
    
    @Autowired
	private ProductBusinessStatusMapper productBusinessStatusMapper;
    
	public Page<ProductBusinessStatus> findByPage(Criteria criteria){
	    return new Page<ProductBusinessStatus>(productBusinessStatusMapper.findByPageCount(criteria), productBusinessStatusMapper.findByPage(criteria));
	}
	
	public List<ProductBusinessStatus> find(ProductBusinessStatus productBusinessStatus){
	    return productBusinessStatusMapper.find(productBusinessStatus);
	}

	 public ProductBusinessStatus findByProductId(Long productId){
		 return productBusinessStatusMapper.findByProductId(productId);
	 }
	
	public ProductBusinessStatus findById(Long productBusinessId){
	    return productBusinessStatusMapper.findById(productBusinessId);
	}
	
	public List<ProductBusinessStatus> findAll(){
	    return productBusinessStatusMapper.findAll();
	}
	
	public void save(ProductBusinessStatus productBusinessStatus){
	  try {
	     productBusinessStatusMapper.insert(productBusinessStatus);
       }catch (Exception e) {
           e.printStackTrace();
       }
	}
	
	public void update(ProductBusinessStatus productBusinessStatus){
		productBusinessStatusMapper.update(productBusinessStatus);
	}
	
	public void removeProductBusinessStatus(String ids){
	  for (String productBusinessIdString : ids.split(",")) {
        Long productBusinessId = Long.parseLong(productBusinessIdString);
        productBusinessStatusMapper.delete(productBusinessId);
      }
	}
	
}
